import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/Login'
import Index from '@/components/Index'
import UserCenter from '@/components/UserCenter'
import UserInfo from '@/components/UserInfo'
import Orders from '@/components/Orders'
import User from '@/components/User'
import Role from '@/components/Role'
import WorkTickets from '@/components/WorkTickets'
import InspectionInformation from '@/components/InspectionInformation'
import StorageUnit from '@/components/StorageUnit'
import ProInfo from '@/components/ProInfo'
import MatInfo from '@/components/MatInfo'
import ProType from '@/components/ProType'
import DashBoards from '@/components/DashBoards'
import MesUnit from '@/components/MesUnit'
import OperInsp from '@/components/OperInsp'
import ProcessManagement from '@/components/ProcessManagement';

import FirstInsp from '@/components/FirstInsp'
import ProductInsp from '@/components/ProductInsp'
//在main.js引入qs  
import qs from  'qs'  

//配全局属性配置，在任意组件内可以使用this.$qs获取qs对象 
Vue.prototype.$qs = qs
Vue.use(Router);

const originalPush = Router.prototype.push;

Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Login',
      component: Login
    },
    {
      path: '/index',
      name: 'Index',
      component: Index,
      children:[
        {
          path: '/usercenter',
          name: 'UserCenter',
          component: UserCenter,
          children:[
            {
              path: '/userInfo',
              name: 'UserInfo',
              component: UserInfo,
            },
          ]
        },
        {
          path: '/orders',
          name: 'Orders',
          component: Orders,
        },
        {
          path: '/system/user',
          name: 'User',
          component: User
        },
        {
          path: '/system/role',
          name: 'Role',
          component: Role
        },
        {
          path: '/worktickets',
          name: 'WorkTickets',
          component: WorkTickets
        },
        {
          path: '/irs',
          name: 'InspectionInformation',
          component: InspectionInformation
        },
        {
          path: '/storageunit',
          name: 'StorageUnit',
          component: StorageUnit
        },
        {
          path: '/proinfo',
          name: 'ProInfo',
          component: ProInfo
        },
        {
          path: '/matInfo',
          name: 'MatInfo',
          component: MatInfo
        },
        {
          path: '/protype',
          name: 'ProType',
          component: ProType
        },
        {
          path: '/dashboards',
          name: 'DashBoards',
          component: DashBoards
        },
        {
          path: '/mes/unit',
          name: 'MesUnit',
          component: MesUnit
        },
        {
          path: '/operInsp',
          name: 'OperInsp',
          component: OperInsp
        },
        {
          path: '/processManagement',
          name: 'ProcessManagement',
          component: ProcessManagement
        },
        {
          path: '/firstInsp',
          name: 'FirstInsp',
          component: FirstInsp
        },
        {
          path: '/productInsp',
          name: 'ProductInsp',
          component: ProductInsp
        },
      ]
    }
  ]
})
